<?php

$sql = "
CREATE TABLE IF NOT EXISTS " . tablename('tim_quiz_user') . " (
 `id` int(10) unsigned  AUTO_INCREMENT,
 `uniacid` int(11) NOT NULL,
 `openid` varchar(200) NOT NULL,
 `nickname` varchar(100) NOT NULL,
 `headimgurl` varchar(200) NOT NULL,
 `score` int(10),
 `tcent` int(5),
 `answer_time` date,
 `isshare` boolean DEFAULT false, 
 `hnum` int(5),
 `lost_time` int(11),
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
pdo_query($sql);

if(!pdo_fieldexists('tim_quiz_setting', 'adv')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `adv` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'adv_link')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `adv_link` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'total')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `total` int(5) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'tnum')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `tnum` int(5) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'dtnum')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `dtnum` int(5) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'duration')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `duration` int(5) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'prize')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `prize` text ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'rule')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `rule` text ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'link')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `link` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'link1')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `link1` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'link2')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `link2` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'link3')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `link3` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'link4')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `link4` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'text_url')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `text_url` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'share_title')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `share_title` varchar(100) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'share_icon')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `share_icon` varchar(200) ;");
}
if(!pdo_fieldexists('tim_quiz_setting', 'share_content')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_setting')." ADD `share_content` varchar(200) ;");
}

if(!pdo_fieldexists('tim_quiz', 'pagenum')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz')." ADD `pagenum` int(3) ;");
}
if(!pdo_fieldexists('tim_quiz', 'cent')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz')." ADD `cent` float ;");
}
if(!pdo_fieldexists('tim_quiz_user', 'answer_time')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_user')." ADD `answer_time` date ;");
}
if(!pdo_fieldexists('tim_quiz_user', 'isshare')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_user')." ADD `isshare` boolean DEFAULT false;");
}
if(!pdo_fieldexists('tim_quiz_user', 'hnum')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_user')." ADD `hnum` int(5);");
}
if(!pdo_fieldexists('tim_quiz_user', 'hnum')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_user')." ADD `hnum` int(5);");
}
if(!pdo_fieldexists('tim_quiz_user', 'lost_time')) {
	pdo_query("ALTER TABLE ".tablename('tim_quiz_user')." ADD `lost_time` int(11);");
}